package com.wu.ssm.mybatis;



/**
 * Created by wzf on 2018/11/11/011.
 */
public class MyDefaultSqlsession implements MySqlSession{


    private final MyConfiguration configuration;

    private Excutor excutor = new SimpleExcutor();

    private final boolean autoCommit;

    public MyDefaultSqlsession(MyConfiguration configuration, boolean autoCommit) {
        this.configuration = configuration;
        this.autoCommit = autoCommit;
    }

    @Override
    public <T> T selectOne(String statement) {
        return null;
    }

    public <T> T selectOne(String statement, Object [] parameter) {


        return excutor.query(configuration.mappedStatements.get(statement), parameter);
    }

  /*  public <T> T getMapper(Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new MyMapperProxy<T>(this,clazz));
    }*/


    public <T> T getMapper(Class<T> clazz) {
        final  MyMapperProxyFactory<T> mapperProxyFactory = new MyMapperProxyFactory<T>();
        return (T) mapperProxyFactory.newInstance(this);
    }

}

